//
//  ZCVisitorView.swift
//  weibo
//
//  Created by Ning Xie on 16/8/8.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit
import SnapKit

class ZCVisitorView: UIView {

    
    var loginClosure :(()->())?
    
    
    //创建中间的三个视图
    private lazy var circleImageView : UIImageView = UIImageView(image: UIImage(named: "visitordiscover_feed_image_smallicon"))
    private lazy var maskImageView : UIImageView = UIImageView(image: UIImage(named: "visitordiscover_feed_mask_smallicon"))
    private lazy var iconImageView : UIImageView = UIImageView(image: UIImage(named: "visitordiscover_feed_image_house"))
    
    private lazy var messageLab : UILabel = {
    
        let label = UILabel()
        label.text = "关注一些人，回这里看看有什么惊喜关注一些人，回这里看看有什么惊喜"
        label.numberOfLines = 0
        label.font = UIFont.systemFontOfSize(14)
        label.textAlignment = .Center
        label.textColor = UIColor.darkGrayColor()
        
        return label
        
        
    }()
    
    //创建注册按钮
    private lazy var registButton : UIButton = {
       
        let button = UIButton()
        
        button.setTitle("注册", forState: .Normal)
        button.addTarget(self, action:#selector(ZCVisitorView.registButtonAction), forControlEvents: .TouchDown)
        button.setBackgroundImage(UIImage(named:"common_button_white_disable"), forState: .Normal)
        button.setTitleColor(UIColor.darkGrayColor(), forState: .Normal)
        button.setTitleColor(UIColor.orangeColor(), forState: .Highlighted)
        button.titleLabel?.font = UIFont.systemFontOfSize(15)
        
        return button
    }()
    
    //创建登录按钮
    private lazy var loginButton : UIButton = {
       
        let button = UIButton()
        
        button.setTitle("登录", forState: .Normal)
        button.addTarget(self, action: #selector(ZCVisitorView.loginButtonAction), forControlEvents: .TouchDown)
        button.setBackgroundImage(UIImage(named:"common_button_white_disable"), forState: .Normal)
        button.setTitleColor(UIColor.darkGrayColor(), forState: .Normal)
        button.setTitleColor(UIColor.orangeColor(), forState: .Highlighted)
        button.titleLabel?.font = UIFont.systemFontOfSize(15)
        
        return button

    }()
    
    //注册按钮的点击事件
    @objc private func registButtonAction() {
        
        print("注册")
        //执行跳转第三方控制器闭包
        loginClosure?()
        
    }
    
    //登录按钮的点击事件
    @objc private func loginButtonAction(){
       
        print("登录")
        //执行跳转第三方控制器闭包
        loginClosure?()
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        //布局界面
        setupUI()
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    //布局界面方法
    private func setupUI(){
        backgroundColor = UIColor(white: 237/255, alpha: 1)
        
        addSubview(circleImageView)
        addSubview(maskImageView)
        addSubview(iconImageView)
        addSubview(messageLab)
        addSubview(registButton)
        addSubview(loginButton)
        
        circleImageView.snp_makeConstraints { (make) in
            make.center.equalTo(self)
        }
        maskImageView.snp_makeConstraints { (make) in
            make.center.equalTo(self)
        }
        iconImageView.snp_makeConstraints { (make) in
            make.center.equalTo(self)
        }
        messageLab.snp_makeConstraints { (make) in
            make.top.equalTo(iconImageView.snp_bottom)
            make.centerX.equalTo(self)
            make.width.equalTo(224)
        }
        registButton.snp_makeConstraints { (make) in
            make.leading.equalTo(messageLab)
            make.top.equalTo(messageLab.snp_bottom).offset(10)
            make.right.equalTo(self.snp_centerX).offset(-10)
            make.height.equalTo(35)
        }
        loginButton.snp_makeConstraints { (make) in
            make.trailing.equalTo(messageLab)
            make.top.equalTo(registButton)
            make.size.equalTo(registButton)
        }
        
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}
